fix: calculate run memory min/max memory clamping#986
Merged
Conversation
tobice
approved these changes
Jan 5, 2026
| // If not provided via flag, try to load from actor.json | ||
| if (!memoryExpression) { | ||
| memoryExpression = await this.getExpressionFromConfig(); | ||
| const { |
Contributor
There was a problem hiding this comment.
(nit) You should be able to do:
let memoryExpression: string | undefined = defaultMemoryMbytes;
let minMemoryMbytes = 0;
let maxMemoryMbytes = Infinity;
if (!memoryExpression) {
({ defaultMemoryMbytes: memoryExpression, minMemoryMbytes, maxMemoryMbytes } = await this.getExpressionFromConfig());
}I'm not sure about the exact syntax but it should be possible to destruct into variables defined via let.
vladfrangu
reviewed
Jan 5, 2026
| @@ -63,10 +69,16 @@ export class ActorCalculateMemoryCommand extends ApifyCommand<typeof ActorCalcul | |||
| const { input, defaultMemoryMbytes, ...runOptions } = this.flags; | |||
|
|
|||
| let memoryExpression: string | undefined = defaultMemoryMbytes; | |||
Member
There was a problem hiding this comment.
Nit: maybe extract all this logic inside a function in the class and return it for the run method to consume instead
| return localConfig?.defaultMemoryMbytes?.toString(); | ||
| return { | ||
| defaultMemoryMbytes: localConfig?.defaultMemoryMbytes?.toString(), | ||
| minMemoryMbytes: localConfig?.minMemoryMbytes as number, |
Member
There was a problem hiding this comment.
This cast is a lie, its number | undefined
Contributor
Author
There was a problem hiding this comment.
Ideally we need to define actor.json type in future, that will help in such cases
vladfrangu
approved these changes
Jan 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates the dynamic run memory calculation (added in #980) to respect the memory limits set in
actor.json.The final memory value is now clamped between
minMemoryMbytesandmaxMemoryMbytes.In case user provides
defaultMemoryMbytesvia flag, we're not checking for min/max memory from config, because it feels confusing.